
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_SP_HENT_STANDARD_VAERDI]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[EBAS_SP_HENT_STANDARD_VAERDI]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [DBO].[EBAS_SP_HENT_STANDARD_VAERDI] 
	@session varchar(255),
	@komponent varchar(255)
WITH ENCRYPTION
AS
	DECLARE @rettighed int
	
	SET NOCOUNT ON
	
	CREATE TABLE #temp ( rett int )
	INSERT INTO #temp (rett)
	EXEC EBAS.DBO.EBAS_SP_SIKKERHED_VERIFICER_SESSION @session	

	SET @rettighed = (SELECT IsNull(MAX(rett),0) FROM #temp)
	
	IF 0 < @rettighed 
	BEGIN		
		SELECT GUID, KOMPONENT_NAVN, VAERDI, POSITION, DEAKTIVERET, SKJULT
		FROM EBAS_STANDARD_VAERDI
		WHERE KOMPONENT_NAVN = @komponent
	END
	ELSE
		SELECT GUID, KOMPONENT_NAVN, VAERDI, POSITION, DEAKTIVERET, SKJULT
		FROM EBAS_STANDARD_VAERDI
		WHERE KOMPONENT_NAVN IS NULL
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
